﻿using CarterWechatServer.WebApi.AuthorizationProvider;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.OAuth;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CarterWechatServer.WebApi.App_Start
{
    /// <summary>
    /// api授权配置
    /// </summary>
    public class OAuth2Config
    {
        public static void Register(IAppBuilder app)
        {
            OAuthAuthorizationServerOptions options = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp = true,
                AuthenticationMode = AuthenticationMode.Active,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),

                Provider = new OpenAuthorizationProvider()
            };
            app.UseOAuthBearerTokens(options);
        }
    }
}